CORELIB_NAME=libpipc.so
CORELIB_FILES= src/plumber.cpp src/session.cpp src/routingindex.cpp src/query.cpp
CORELIB_OBJECTS	= $(CORELIB_FILES:src/%.cpp=%.o)

CORELIB_COMPILE_FLAGS= -Wall -fPIC -O2
CORELIB_LIBS= -L../build -lboost_thread
CORELIB_LINK_FLAGS= -shared -Wl,-soname,$(CORELIB_NAME) $(CORELIB_LIBS) -o $(CORELIB_NAME)
CPP=g++
MAKE=make

all: slib

system: slib
	cp $(CORELIB_NAME) ../build/

%.o: src/%.cpp
	$(CPP) $(CORELIB_COMPILE_FLAGS) -c -o $@  $< $(CXXFLAGS)

slib: $(CORELIB_OBJECTS)
	$(CPP) $(CORELIB_LINK_FLAGS) $(CORELIB_OBJECTS)

docs:
	rm -rf doc/
	doxygen doxyfile.cfg
	cd doc/latex/; $(MAKE); mv refman.pdf ../libpland.pdf
	rm -rf doc/latex

.PHONY	: clean open

clean:
	rm -rf $(CORELIB_OBJECTS) $(CORELIB_NAME) doc/ testbench log.txt

open:
	geany  src/*.cpp lib/*.hpp &

bin:  $(CORELIB_OBJECTS) main.cpp
	$(CPP) $(CORELIB_COMPILE_FLAGS) -c -o main.o  main.cpp $(CXXFLAGS)
	g++ main.o -Wl,--rpath,. $(CORELIB_OBJECTS) $(CORELIB_LIBS) -o plumber
